<?php

namespace App\Http\Controllers;

use AndPHP\OutPut\OutPut;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests,OutPut;

    protected $wlimit = 0;
    protected $alimit = 0;
    protected $page = 1;
    protected $limit = 10;

    public function __construct(){
        $this->wlimit = config('app.wechat_limit');
        $this->alimit = config('app.limit');
        $this->page = request()->input('page',1);
        $this->limit = request()->input('size',10);
    }

    /**
     * writeJson 方法
     * @param int $statusCode 0成功 1失败
     * @param null $result 结果
     * @param null $msg 消息提示
     * @return bool
     */
    protected function writeJson($statusCode = 0,$result = null,$msg = null){
        $data = [
            "code"  => $statusCode,
            "data"  => $result,
            "msg"   => $msg ?? 'SUCCESS'
        ];
        return response()->json($data);
    }
}
